<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Cache;

class District extends Model
{
    protected $table = 'district';

    /**
     * 根据id找到地区名
     * @param  [type] $key [description]
     * @return [type]      [description]
     */
   	public function cacheFindById($id){
   		$district = Cache::get(config('app.name').':district:'.$id);
   		if($district){
    		return $district;
    	}

    	$district = self::find($id);
    	if(!$district){
    		return false;
    	}
    	Cache::forever(config('app.name').':district:'.$id, $district);
    	return $district;
   	}
}
